import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:vape_xe/utils/utils.dart';
import 'package:vape_xe/values/values.dart';

class DialogView extends Dialog {
  final String message;
  final Function? onConfirmEvent;
  final Function? onCancelEvent;

  const DialogView({super.key, required this.message, this.onCancelEvent, this.onConfirmEvent});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 48.w),
        width: double.infinity,
        decoration: BoxDecoration(
          color: Colors.black,
          borderRadius: 20.radius,
          boxShadow: [Shadows.dialogShadow],
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Padding(
              padding: EdgeInsets.all(30.w),
              child: Text(message,
                  style: TextStyle(
                    fontSize: 20.sp,
                    fontFamily: 'Montserrat',
                    fontWeight: FontWeight.bold,
                  )),
            ),
            Divider(
              height: 0.5.h,
              color: Colors.white10,
            ),
            Row(
              children: [
                onCancelEvent == null
                    ? Container()
                    : Expanded(
                        child: TextButton(
                          onPressed: () {
                            onCancelEvent?.call();
                            Navigator.pop(context);
                          },
                          child: Text(
                            'Cancel'.tr,
                            style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.sp, color: AppColors.thirdText),
                          ),
                        ),
                      ),
                Expanded(
                  child: TextButton(
                    onPressed: () {
                      onConfirmEvent?.call();
                      Navigator.pop(context);
                    },
                    child: Text(
                      'Confirm'.tr,
                      style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.sp, color: AppColors.primaryText),
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
